package com.hyts.bmsp.plugin;

import com.hyts.bmsp.error.ProcessError;
import org.apache.log4j.Logger;

import com.jfinal.config.Plugins;
import com.jfinal.plugin.ehcache.EhCachePlugin;

/**
 * @ClassName: EhcacheSupportPlugin
 * @Description: Ehcache缓存系统架构插件支持类<br>
 * 				 EhCachePlugin 是 JFinal 集成的缓存插件，<br>
 * 				  通过使用 EhCachePlugin 可以提高系统的并发<br>
				  访问速度。
 * @author: 李博/Alex
 * @date: 2017-1-9 下午09:41:22
 */
public final class EhcacheSupportPlugin {

	/**
	 * @fieldName: EHCACHE_CONFIG_FILE_PATH
	 * @fieldType: String
	 * @Description: 系统ECHACHE数据库连接池参数配置信息
	 */
	private static final String EHCACHE_CONFIG_FILE_PATH = "ehcache.xml";
	
	/**
	 * @fieldName: logger
	 * @fieldType: Logger
	 * @Description: Logger日志输出器
	 */
	private static final Logger logger = Logger.getLogger(EhcacheSupportPlugin.class);
	
	/**
	 * @fieldName: ehcachePlugin
	 * @fieldType: EhCachePlugin
	 * @Description: Ehcache缓存功能插件
	 */
	private static EhCachePlugin ehcachePlugin = null;
	
	
	/**
	 * @Title:EhcacheSupportPlugin
	 * @Description:EcachePlugin插件功能信息加载初始化
	 * @param me
	 */
	public EhcacheSupportPlugin(Plugins me){
		if(me == null)
			throw new ProcessError("传入的插件总体加载对象为空!");
		if(ehcachePlugin == null)
			ehcachePlugin = new EhCachePlugin(this.getClass().getResourceAsStream(EHCACHE_CONFIG_FILE_PATH));
		me.add(ehcachePlugin);
	}

	/**
	 * @Title: getEhcachePlugin
	 * @Description: 获取EhcachePlugin插件
	 * @return
	 * @return: EhCachePlugin
	 */
	public static EhCachePlugin getEhcachePlugin() {
		return ehcachePlugin;
	}

}
